<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%--
  ~ Copyright (c) 2017 22420103@QQ.COM 版权所有
  ~
  --%>

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<meta name="description" content="Draggabble Widget Boxes with Persistent Position and State" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
		<c:set var="ctx" value="${pageContext.request.contextPath}" />
		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="${ctx }/static/assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="${ctx }/static/assets/font-awesome/4.5.0/css/font-awesome.min.css" />
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${ctx }/static/assets/css/jquery-ui.custom.min.css" />
		<!-- text fonts -->
		<link rel="stylesheet" href="${ctx }/static/assets/css/fonts.googleapis.com.css" />
		<!-- ace styles -->
		<link rel="stylesheet" href="${ctx }/static/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
		<!--[if lte IE 9]>
			<link rel="stylesheet" href="${ctx }/static/assets/css/ace-part2.min.css" class="ace-main-stylesheet" />
		<![endif]-->
		<link rel="stylesheet" href="${ctx }/static/assets/css/ace-skins.min.css" />
		<link rel="stylesheet" href="${ctx }/static/assets/css/ace-rtl.min.css" />
		<!--[if lte IE 9]>
		  <link rel="stylesheet" href="${ctx }/static/assets/css/ace-ie.min.css" />
		<![endif]-->
		<!-- inline styles related to this page -->
		<!-- ace settings handler -->
		<script src="${ctx }/static/assets/js/ace-extra.min.js"></script>
		<!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->
		<!--[if lte IE 8]>
		<script src="${ctx }/static/assets/js/html5shiv.min.js"></script>
		<script src="${ctx }/static/assets/js/respond.min.js"></script>
		<![endif]-->
		<script src="${ctx }/static/assets/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript" src="${ctx }/static/js/jquery.tips.js"></script>
		<script src="${ctx }/static/assets/js/tree.min.js"></script>
		<script src="${ctx }/static/assets/js/ace-elements.min.js"></script>
		<script src="${ctx }/static/assets/js/ace.min.js"></script>
	</head>

	<body style="background-color: #fff;">
		<div id=context>
			<div class="row">
				<div class="col-xs-12">
					<div class="page-header">
						<h1>
							<a href="${ctx}/admin/systemManager/menuManager">菜单管理</a>
							<small>
								<i class="ace-icon fa fa-angle-double-right"></i>
								修改菜单
							</small>
						</h1>
					</div>
					<!-- PAGE CONTENT BEGINS -->
					<form class="form-horizontal" id="adminMenuForm" name="myform" role="form">
						<input type="hidden" name="id" value="${menu.id}" />
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">菜单名称</label>
							<div class="col-sm-9">
								<input type="text" id="name" name="name" placeholder="菜单名称" class="col-xs-10 col-sm-5" value="${menu.name}"/>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">菜单url</label>
							<div class="col-sm-9">
								<input type="text" id="url" name="url" placeholder="菜单url" class="col-xs-10 col-sm-5" value="${menu.url}"/>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">菜单父ID</label>
							<div class="col-sm-9">
								<input type="text" id="parentId" name="parentId" placeholder="菜单父ID" class="col-xs-10 col-sm-5" value="${menu.parentId}"/>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">菜单排序</label>
							<div class="col-sm-9">
								<input type="text" id="orderBy" name="orderBy" placeholder="菜单排序" class="col-xs-10 col-sm-5" value="${menu.orderBy}"/>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">菜单标志</label>
							<div class="col-sm-9">
								<input type="text" id="menuNo" name="menuNo" placeholder="菜单标志" class="col-xs-10 col-sm-5" value="${menu.menuNo}"/>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">菜单图标</label>
							<div class="col-sm-9">
								<input type="text" id="icon" name="icon" placeholder="菜单图标" class="col-xs-10 col-sm-5" value="${menu.icon}"/>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">菜单类型</label>
							<div class="col-sm-9">
								<input type="text" id="type" name="type" placeholder="菜单类型" class="col-xs-10 col-sm-5" value="${menu.type}"/>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">菜单授权码</label>
							<div class="col-sm-9">
								<input type="text" id="key" name="key" placeholder="菜单授权码" class="col-xs-10 col-sm-5" />
							</div>
						</div>

						<div class="form-group" >
							<label class="col-sm-3 control-label no-padding-right"></label>
							<div class="col-sm-9 col-xs-10 col-sm-5" style="padding:10px;color:#f00;">
								<h4 id="messageText" class="widget-title lighter smaller"></h4>
							</div>
						</div>
						<div class="clearfix form-actions">
							<div class="col-md-offset-3 col-md-9">
								<button class="btn btn-info" type="button" onclick="sumbitMenu()">
									<i class="ace-icon fa fa-check bigger-110"></i>
									确认
								</button>
								&nbsp; &nbsp; &nbsp;
								<button class="btn" type="reset">
									<i class="ace-icon fa fa-undo bigger-110"></i>
									取消
								</button>
							</div>
						</div>
					</form>

				</div><!-- /.col -->
			</div><!-- /.row -->
		</div>
	</body>
	<script>
		var ctx = "${ctx}";
        //客户端校验
        function check() {
            if ($("#name").val() == "") {
                $("#name").tips({
                    side : 1,
                    msg : '菜单名称不得为空',
                    bg : '#AE81FF',
                    time : 3
                });
                $("#name").focus();
                return false;
            }
            return true;
        }

		function sumbitMenu() {
            if(!check()){
                return;
			}
            var data = $("#adminMenuForm").serialize();
            $.ajax({
                type:"POST",
                url:"updateMenuInfo",
                data:data,
				dataType:"json",
                cache:false,
                success:function(data){
                    if(data.code == "1"){
                        window.location.href="${ctx}/admin/systemManager/menuManager";
                    }else {
                        $("#messageText").html("温馨提示：" + data.msg);
                    }
                }
            });
        }
	</script>

</html>
